import Vue from 'vue'
import VueRouter from 'vue-router'
const Login=() => import(/* webpackChunkName: "login" */ '../views/Login.vue');
const Home=() => import(/* webpackChunkName: "home" */ '../views/Home.vue');
const Person=() => import(/* webpackChunkName: "home" */ '../views/home/Person.vue');
const Factory=() => import(/* webpackChunkName: "home" */ '../views/home/Factory.vue');
const Record=() => import(/* webpackChunkName: "home" */ '../views/home/Record.vue');
const QRCode=() => import(/* webpackChunkName: "home" */ '../views/home/QRCode.vue');

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home,
    redirect:'/login',
    children:[
      {
        path: 'person',
        name: 'person',
        component: Person,
      },
      {
        path: 'factory',
        name: 'factory',
        component: Factory,
      },
      {
        path: 'record',
        name: 'record',
        component: Record,
      },
      {
        path: 'qrcode',
        name: 'qrcode',
        component: QRCode,
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: Login
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
